#include <iostream>
using namespace std;

#include <stack>
#include <stdio.h>
#include <string.h>

#define BUFFER_SIZE 20


typedef struct Info
{
    int age;
    char name[BUFFER_SIZE];
}Info;

int main()
{
    #if 0
    /* --基础数据类型 */
    stack<int> mystack;

    mystack.push(11);
    mystack.push(22);
    mystack.push(33);

    int len = mystack.size();
    printf("len:%d\n", len);

    int topVal = 0;
    while(!mystack.empty())
    {
        topVal = mystack.top();
        printf("topVal:%d\n", len);
        mystack.pop();
    }
    #else
    

    /* 复合数据类型*/
    stack <Info> mystack;
    Info stu1, stu2, stu3;

    /* 清楚脏数据*/
    memset(&stu1, 0, sizeof(stu1));
    memset(&stu2, 0, sizeof(stu2));
    memset(&stu3, 0, sizeof(stu3));

    stu1.age = 20;
    strncpy(stu1.name, "zhangsan", sizeof(stu1.name) - 1);

    stu2.age = 20;
    strncpy(stu2.name, "lisi", sizeof(stu2.name) - 1);

    stu3.age = 20;
    strncpy(stu3.name, "wangwu", sizeof(stu3.name) - 1);

    /* 压栈*/
    mystack.push(stu1);
    mystack.push(stu2);
    mystack.push(stu3);

    int len = mystack.size();
    printf("len:%d\n", len);

    Info topValue;
    memset(&topValue, 0, sizeof(topValue));
    while(!mystack.empty())
    {
        topValue = mystack.top();
        printf("age:%d,\tname:%s\n", topValue.age, topValue.name);
        mystack.pop();
    }
    


    #endif

    return 0;
}